﻿<!--#include file="../Include/Config.asp"-->
<link rel="stylesheet" href="../Css/Admin.css" type="text/css" />
<script language="javascript" type="text/javascript" src="../Js/QuestAdd.js"></script>
<script language="javascript" type="text/javascript" src="../Js/QuestTz.js"></script>
<%
Survey_id=request.QueryString("Survey_id")
Question_id=request.QueryString("Question_id")
sql="select * from question where Question_id="&Question_id
rs.open sql,conn,1,1
if rs.eof then
	Call ShowAlert("参数错误","")
else
	Qtype=rs("Question_type")
	Question_content=rs("Question_content")
	Question_jdtz=rs("Question_jdtz")
	Question_answer=rs("Question_answer")
end if
rs.close
if Question_answer<>"" then
	Question_answer=split(Question_answer,"&")
else
    if Qtype<>5 then
		Call ShowAlert("该题目内无选项","")
	end if
end if
select case Qtype
	case "1","2": call type1()
	case "3","4": call type2()
	case "5": call type3()
end select
%>
<div id="question_tz">
<table width="450" border="0" cellspacing="0" cellpadding="0" class="table">
  <tr>
      <th width="85%" nowrap id="question_tz_title" style="cursor:move; font-size:14px;">此问卷下已有的题目</th>
      <th width="15%" align="right" onClick="closewin()" style="cursor:hand;" nowrap title="关闭">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[X]</th>
  </tr>
    <%dim i
    Survey_id=request.QueryString("Survey_id")
    action=request.QueryString("action")
    page_size=10
    sql="select * from survey where Survey_id="&Survey_id&""
    rs.open sql,conn,1,3
    if rs.eof then
    call ShowAlert("参数错误","") 
    end if
    Survey_name=rs("Survey_name")
    response.Write("<title>"&siteName&"---"&Survey_name&"-题目管理</title>")
    if rs("Survey_content")<>"" then
    Survey_content=split(rs("Survey_content"),",")
    if (ubound(Survey_content)+1)\page_size<>(ubound(Survey_content)+1)/page_size then'计算出页数
    page_count=((ubound(Survey_content)+1)\page_size)+1
    else
    page_count=(ubound(Survey_content)+1)\page_size
    end if
    select case action
        case "next"
        if session("page_start")+page_size<=ubound(Survey_content) then'解决多次刷新‘下一页’出现显示异常的原因
        session("page_start")=session("page_start")+page_size
        end if
        case "last"
        session("page_start")=session("page_start")-page_size
        case "end"
        session("page_start")=(page_count-1)*page_size
        case "","start"
        session("page_start")=0
    end select
    if session("page_start")<0 then
    session("page_start")=0
    end if
    if session("page_start")>=ubound(Survey_content) then
    session("page_start")=ubound(Survey_content)
    end if
    page_start=session("page_start")
    page_end=page_start+page_size-1
    if page_end>ubound(Survey_content) then
    page_end=ubound(Survey_content)
    end if
    for i=page_start to page_end
    if not Survey_content(i)="" then
    sql="select * from question where Question_id="&Survey_content(i)&""
    rst.open sql,conn,1,1
    if not rst.eof then
    %>    
  <tr>
    <td width="85%"><li style="list-style:none"><%=i+1%>、<a href="#" onClick="Quest_selected('<%=rst("Question_id")%>')" title="<%=rst("Question_content")%>"><%=Intcpt(rst("Question_content"),26)%></a></li></td>
    <td width="15%"><a href="#" onClick="showModalDialog('QuestionShow.asp?Survey_id=<%=Survey_id%>&Question_id=<%=rst("Question_id")%>',window,'dialogHeight:350px;dialogWidth:360px;dialogleft:220px;help:no;status:no;scroll:no');" >查看</a>&nbsp;<a href="#" onClick="Quest_selected('<%=rst("Question_id")%>')">选择</a>
    </td>
  </tr>
<%
else
%>
  <tr>
    <td><li style="list-style:none"><%=i+1%>、题目在题库中已经被删除！请删除</li></td>
    <td><a href="QuestionDel.asp?Survey_id=<%=Survey_id%>&Question_id=<%=Survey_content(i)%>&i=<%=i%>">删除</a></td>
  </tr>
<%
end if
rst.close
end if
next
%>  
  <tr>
    <td colspan="2">
    <div id="bottom_pagebox" style="padding-right:25px;">
当前第<%=(session("page_start")/page_size)+1%>页
  <%if session("page_start")=0 then%>首页
  <%else%><a href="QuestionList.asp?Survey_id=<%=Survey_id%>&action=start">首页</a>
  <%end if%>
  <%if (session("page_start")-page_size)>=0 then%>
  <a href="QuestionList.asp?Survey_id=<%=Survey_id%>&action=last">上一页</a>
  <%else%>上一页
  <%end if%>				
  <%if (session("page_start")+page_size)<=ubound(Survey_content) then%> 
  <a href="QuestionList.asp?Survey_id=<%=Survey_id%>&action=next">下一页</a>
  <%else%>下一页
  <%end if%>				
  <%if (session("page_start")+page_size)<=ubound(Survey_content) then%>
  <a href="QuestionList.asp?Survey_id=<%=Survey_id%>&action=end">尾页</a>
  <%else%>
  尾页
  <%end if%>
  共<%=page_count%>页/<%=ubound(Survey_content)+1%>个题目&nbsp;每页<%=page_size%>个</div>  </td>
  </tr>
<%
else
response.Write("<td colspan=""2"">本问卷下暂时没有任何题目，请&nbsp;&nbsp;<a href=""QuestionAdd.asp?Survey_id="&Survey_id&""">添加</td>")
end if
rs.close
%>
  <tr>
    <td colspan="2">
         注：单击选定要跳转至的题目
    </td>
  </tr>
</table>
</div>
<%sub type1()%>
<form name="form1" action="QuestionSave.asp?Survey_id=<%=Survey_id%>&Question_id=<%=Question_id%>&action=tz" method="post" onsubmit="SubTz();">
问题：<input name="Question_content" type="text" size="40" value="<%=Question_content%>">
<br/><br/>
备选项：
<ul type="A" id="ulAnswer">
<%
if Question_jdtz<>"" then
Question_jdtz=split(Question_jdtz,"&")
    for i=0 to ubound(Question_answer)
	    if Question_jdtz(i)="null" then
			I1 "<li><input type=""text"" name=""Answer"" value="""&Question_answer(i)&""">设置跳转"
			I1 "<input type=""checkbox"" name=""check_box"" id=""tz"&i&""" value="""&i&""" onClick=""getQuestList('tz"&i&"');"">"
			I1 "跳至：<input type=""text"" name=""check_box_text"" id=""tz"&i&"_text"" size=""5"" readonly=""readonly"">"
			I1 "</li>"
		else 
		    if Question_jdtz(i)<>"over" then
				I1 "<li><input type=""text"" name=""Answer"" value="""&Question_answer(i)&""">设置跳转"
				I1 "<input type=""checkbox"" name=""check_box"" id=""tz"&i&""" value="""&i&""" checked=""checked"" onClick=""getQuestList('tz"&i&"');"">"
				I1 "跳至：<input type=""text""  name=""check_box_text"" id=""tz"&i&"_text"" value="""&Question_jdtz(i)&""" size=""5"" readonly=""readonly"">"
				I1 "</li>"
			else
				I1 "<li><input type=""text"" name=""Answer"" value="""&Question_answer(i)&""">已经设置截断，不能设置跳转"
				I1 "<input type=""hidden"" name=""check_box_text"" id=""tz"&i&""" value="""&i&""">"
				I1 "</li>"
			end if
		end if	
	next
else
	i=0
	for each QueAns in Question_answer
	I1 "<li><input type=""text"" name=""Answer"" value="""&QueAns&""">设置跳转"
	I1 "<input type=""checkbox"" name=""check_box"" id=""tz"&i&""" value="""&i&""" onClick=""getQuestList('tz"&i&"');"">"
	I1 "跳至：<input type=""text"" name=""check_box_text"" id=""tz"&i&"_text"" size=""5"">"
	I1 "</li>"
	i=i+1
	next
end if
%>
</ul>
<div id="button">
&nbsp;&nbsp;<input type="submit" name="submit1" value="保存">
&nbsp;&nbsp;<input type="reset" name="reset1" value="取消">
&nbsp;&nbsp;<input type="button" name="Back" value="返回" onClick="location.href='javascript:history.go(-1)';">
</div>
</form>

<%end sub%>

<%sub type2()%>
<form name="form1" action="QuestionSave.asp?Survey_id=<%=Survey_id%>&Question_id=<%=Question_id%>&action=tz" method="post" onsubmit="SubTz();">
问题：<input name="Question_content" type="text" size="40" value="<%=Question_content%>">
<br/><br/>
备选项：
<ul type="A" id="ulAnswer">
<%
if Question_jdtz<>"" then
	Question_jdtz=split(Question_jdtz,"&")
    for i=0 to (ubound(Question_answer)-1)
	    if Question_jdtz(i)="null" then
			I1 "<li><input type=""text"" name=""Answer"" value="""&Question_answer(i)&""">&nbsp;设置跳转"
			I1 "<input type=""checkbox"" name=""check_box"" id=""tz"&i&""" value="""&i&""" onClick=""getQuestList('tz"&i&"');"">"
			I1 "跳至：<input type=""text"" name=""check_box_text"" id=""tz"&i&"_text"" size=""5"" readonly=""readonly"">"
			I1 "</li>"
		else 
		    if Question_jdtz(i)<>"over" then
				I1 "<li><input type=""text"" name=""Answer"" value="""&Question_answer(i)&""">&nbsp;设置跳转"
				I1 "<input type=""checkbox"" name=""check_box"" id=""tz"&i&""" value="""&i&""" checked=""checked"" onClick=""getQuestList('tz"&i&"');"">"
				I1 "跳至：<input type=""text""  name=""check_box_text"" id=""tz"&i&"_text"" value="""&Question_jdtz(i)&""" size=""5"" readonly=""readonly"">"
				I1 "</li>"
			else
				I1 "<li><input type=""text"" name=""Answer"" value="""&Question_answer(i)&""">&nbsp;已经设置截断，不能设置跳转"
				I1 "<input type=""hidden"" name=""check_box_text"" id=""tz"&i&""" value="""&i&""">"
				I1 "</li>"
			end if
		end if	
	next
    i=ubound(Question_answer)
    if Question_jdtz(i)="null" then
		I1 "<li><input type=""text"" name=""Answer"" value="""&Question_answer(i)&""">&nbsp;"
		I1 "<input type=""text"" name=""Answer_2"" readonly=""true"" value=""用户在此框输入自定义文本"">"
	    I1 "设置跳转"
        I1 "<input type=""checkbox"" name=""check_box"" id=""tz"&i&""" value="""&i&""" onClick=""getQuestList('tz"&i&"');"">"
        I1 "跳至：<input type=""text"" name=""check_box_text"" id=""tz"&i&"_text"" size=""5"" readonly=""readonly"">"
        I1 "</li>"
    else 
        if Question_jdtz(i)<>"over" then
			I1 "<li><input type=""text"" name=""Answer"" value="""&Question_answer(i)&""">&nbsp;"
			I1 "<input type=""text"" name=""Answer_2"" readonly=""true"" value=""用户在此框输入自定义文本"">"
			I1 "设置跳转"
            I1 "<input type=""checkbox"" name=""check_box"" id=""tz"&i&""" value="""&i&""" checked=""checked"" onClick=""getQuestList('tz"&i&"');"">"
            I1 "跳至：<input type=""text""  name=""check_box_text"" id=""tz"&i&"_text"" value="""&Question_jdtz(i)&""" size=""5"" readonly=""readonly"">"
            I1 "</li>"
        else
			I1 "<li><input type=""text"" name=""Answer"" value="""&Question_answer(i)&""">&nbsp;"
			I1 "<input type=""text"" name=""Answer_2"" readonly=""true"" value=""用户在此框输入自定义文本"">"
			I1 "设置跳转"
            I1 "已经设置截断，不能设置跳转"
            I1 "<input type=""hidden"" name=""check_box_text"" id=""tz"&i&""" value="""&i&""">"
            I1 "</li>"
        end if
    end if	
else
	i=0
	for i=0 to (ubound(Question_answer)-1)
	I1 "<li><input type=""text"" name=""Answer"" value="""&Question_answer(i)&""">设置跳转"
	I1 "<input type=""checkbox"" name=""check_box"" id=""tz"&i&""" value="""&i&""" onClick=""getQuestList('tz"&i&"');"">"
	I1 "跳至：<input type=""text"" name=""check_box_text"" id=""tz"&i&"_text"" size=""5"">"
	I1 "</li>"
	next
	i=ubound(Question_answer)
	I1 "<li><input type=""text"" name=""Answer"" value="""&Question_answer(i)&""">&nbsp;"
	I1 "<input type=""text"" name=""Answer_2"" readonly=""true"" value=""用户在此框输入自定义文本"">"
	I1 "设置跳转"
	I1 "<input type=""checkbox"" name=""check_box"" id=""tz"&i&""" value="""&i&""" onClick=""getQuestList('tz"&i&"');"">"
	I1 "跳至：<input type=""text"" name=""check_box_text"" id=""tz"&i&"_text"" size=""5"">"
	I1 "</li>"
end if
%>



</ul>
<div id="button">
&nbsp;&nbsp;<input type="submit" name="submit1" value="保存">
&nbsp;&nbsp;<input type="reset" name="reset1" value="取消">
&nbsp;&nbsp;<input type="button" name="Back" value="返回" onClick="location.href='javascript:history.go(-1)';">
</div>
</form>
<%end sub%>

<%sub type3()
Call ShowAlert("问答题不允许设置跳转","")
end sub%>